part of AppUtils;

extension User on _AppUtils {
  void saveUserModel(UserModel userModel) {
    ySave("userModel", userModel.toJson());
  }

  Future<UserModel?> readUserModel() async {
    var userModel = await yRead("userModel");
    return userModel == null ? null : UserModel.fromJson(json.decode(userModel));
  }

  void deleteUserModel() {
    yDelete("userModel");
  }

  Future<bool> checkIsLogon(YPage page, {bool goLogin = false}) async {
    return await readUserModel() != null;
  }
}
